﻿imports System.Text 
Public Class clsLTRFDET
	 inherits ADODBU.Recordset 
	 
	 private mFieldList as New ArrayList 
	 private mStrFieldList as string 
	 private mStrSql as string 
	public Sub New()
	mFieldList.Add("LTRFDET.TRFLLINE")
	mFieldList.Add("LTRFDET.TRFLCOD")
	mFieldList.Add("LTRFDET.BARCODE")
	mFieldList.Add("LTRFDET.TRFLART")
	mFieldList.Add("LTRFDET.TRFLSIZE")
	mFieldList.Add("LTRFDET.TRFLCOLOR")
	mFieldList.Add("LTRFDET.TRFLCREQTY")
	mFieldList.Add("LTRFDET.TRFLPICQTY")
	mFieldList.Add("LTRFDET.TRFLRECQTY")
	mFieldList.Add("LTRFDET.TRFLCRE")
	mFieldList.Add("LTRFDET.TRFLUTIL")
	mFieldList.Add("LTRFDET.TRFLPROG")
		mStrSql = "Select TRFLLINE,TRFLCOD,BARCODE,TRFLART,TRFLSIZE,TRFLCOLOR,TRFLCREQTY,TRFLPICQTY,TRFLRECQTY,TRFLCRE,TRFLUTIL,TRFLPROG from LTRFDET  
	End Sub
	 
	Public overloads Sub Open( cCriteria as string )
		dim cSql as string 
		 cSql=mStrSql & cCriteria
		mybase.IscanUpdate=true 
		try 
		mybase.Open(cSql,"LTRFDET",me.dbConn)
		Catch e as Exception 
		me.ErrMessage =e.message
		end try
	End sub
 
 
	Public Function GetRowList(dbConn as adodbu.dbconn,cCriteria as string) as ADODBU.RowClassList(of clsLTRFDETRow) 
		Dim cmd As System.Data.IDbCommand = dbConn.DBAFactory.GetCommand
		cmd.CommandText = Me.mstrSql & cCriteria 
		cmd.CommandType = CommandType.Text
		cmd.Connection = dbConn.Connection
		Return GetDataFromReader(cmd.ExecuteReader)
	End Function 
 
	Public Function GetRowList() as ADODBU.RowClassList(of clsLTRFDETRow) 
		Return Me.GetDataFromReader(Me.DataTable.CreateDataReader) 
	End Function 
	private Function GetDataFromReader(ByVal rdr As IDataReader) As ADODBU.RowClassList(Of clsLTRFDETRow)
		dim colData as new ADODBU.RowClassList(of clsLTRFDETRow)
		dim xData as clsLTRFDETRow 
		Dim buffer() As Byte
		Dim len As Long 
		Dim mStr As New System.IO.MemoryStream 
		 
		Do While rdr.Read
		 xData = New clsLTRFDETRow()
			If Not rdr.IsDBNull(0) Then 
			 xData.TRFLLINE= rdr.GetInt32(0)
			End If 
			If Not rdr.IsDBNull(1) Then 
			 xData.TRFLCOD= rdr.GetString(1)
			End If 
			If Not rdr.IsDBNull(2) Then 
			 xData.BARCODE= rdr.GetString(2)
			End If 
			If Not rdr.IsDBNull(3) Then 
			 xData.TRFLART= rdr.GetString(3)
			End If 
			If Not rdr.IsDBNull(4) Then 
			 xData.TRFLSIZE= rdr.GetString(4)
			End If 
			If Not rdr.IsDBNull(5) Then 
			 xData.TRFLCOLOR= rdr.GetString(5)
			End If 
			If Not rdr.IsDBNull(6) Then 
			 xData.TRFLCREQTY= rdr.GetInt32(6)
			End If 
			If Not rdr.IsDBNull(7) Then 
			 xData.TRFLPICQTY= rdr.GetInt32(7)
			End If 
			If Not rdr.IsDBNull(8) Then 
			 xData.TRFLRECQTY= rdr.GetInt32(8)
			End If 
			If Not rdr.IsDBNull(9) Then 
			 xData.TRFLCRE= rdr.GetDateTime(9)
			End If 
			If Not rdr.IsDBNull(10) Then 
			 xData.TRFLUTIL= rdr.GetString(10)
			End If 
			If Not rdr.IsDBNull(11) Then 
			 xData.TRFLPROG= rdr.GetString(11)
			End If 
			colData.Add(xData)
		Loop
		rdr.close()
		rdr.Dispose()
		Return colData 
	End Function 
    Public Function GetReader(ByVal dbConn As ADODBU.dbConn, ByVal cCriteria As String) As IDataReader
        Dim cmd As System.Data.IDbCommand = dbConn.DBAFactory.GetCommand
        cmd.CommandText = Me.mStrSql & cCriteria
        cmd.CommandType = CommandType.Text
        cmd.Connection = dbConn.Connection
        Return cmd.ExecuteReader
    End Function
    Public Function GetClassRow() As clsLTRFDETRow
        Dim crData As New clsLTRFDETRow
        crData = GetClassRow(Me.getcurrentdataRow)
        Return crData
    End Function
 
 
	Public Function GetClassRow(recdata as ADODBU.Recordset) as clsLTRFDETRow 
		dim crData as clsLTRFDETRow 
		crData = new clsLTRFDETRow(recdata.getcurrentdataRow) 
		Return crData 
	End Function 
 
 
	Public Function GetClassRow(recdata as DataRow) as clsLTRFDETRow 
		return new clsLTRFDETRow(recdata) 
	End Function 
 
 
	Public Function SaveClassRow(crData as clsLTRFDETRow ,lAddnew as boolean,Optional lTransaction as boolean=false ) as boolean
		dim lSavedata as boolean
		if lAddnew then 
			Mybase.AddNew 
		End if 
		crData.DataSource = me
		crData.SaveToDataSource
		lSaveData=True
		Try 
			Mybase.Update(lTransaction) 
			if Mybase.errMessage.Length<>0 then 
				lSaveData=false
			end if 
		Catch e As Exception
			lSaveData=false
		End Try 
		Return lSavedata 
	End Function 
 

End Class
